package com.laycoding.gateway.config;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * created with IntelliJ IDEA.
 *
 * @author: guidada
 * @date: 2021/05/31/11:34
 * @description:
 */
@Configuration
public class ZkLockConfig {

    @Bean(name = "client")
    public CuratorFramework client(){
        RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
        CuratorFramework client = CuratorFrameworkFactory.newClient("192.168.6.141:2181,192.168.6.132:2181,192.168.6.145:2181", retryPolicy);
        client.start();
        return  client;
    }
}
